//
//  DataDetailVCViewController.m
//  New_Runway
//
//  Created by mack on 2018/2/8.
//  Copyright © 2018年 NelsonJ. All rights reserved.
//

#import "DataDetailVCViewController.h"
#import "DataStructureVC.h"
#import "DetailSubVC.h"

@interface DataDetailVCViewController ()
@property(nonatomic, strong) DataStructureVC *StruVC;
@property(nonatomic, strong) DetailSubVC *DetailVC;
@property (nonatomic, strong) NSArray *titles;
@property(strong, nonatomic)NSArray *childVcs;
@property (weak, nonatomic) ZJScrollSegmentView *segmentView;
@property (weak, nonatomic) ZJContentView *contentView;
@end

@implementation DataDetailVCViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationBarView.titleLabel.text = self.mainTitle;
    self.view.backgroundColor = kColorWhite();
    
    [self creatTopView];
    self.childVcs = [self setupChildVc];
    [self setupContentView];
//    [self initLineView];
    
    

}

-(void)creatTopView{
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    kSelfWeak;
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    //显示遮盖
    style.showCover = NO;
    style.showLine = YES;
    style.scrollLineColor = MAIN_NAV_COLOR();
    style.titleFont = kFontSize(14);
    style.segmentViewBounces = NO;
    // 颜色渐变
    style.autoAdjustTitlesWidth =  YES;
    style.gradualChangeTitleColor = NO;
    style.normalTitleColor = MAIN_FONT_COLOR();
    style.selectedTitleColor = MAIN_NAV_COLOR();
    self.titles = @[@"结构          ", @"明细          "];
    style.titleMargin = 20;
    style.segmentHeight = 40;
    ZJScrollSegmentView *segment = [[ZJScrollSegmentView alloc] initWithFrame:CGRectMake(0, self.navH,Screen_width, 40) segmentStyle:style delegate:nil titles:self.titles titleDidClick:^(ZJTitleView *titleView, NSInteger index) {
        [weakSelf.contentView setContentOffSet:CGPointMake(weakSelf.contentView.bounds.size.width * index, 0.0) animated:YES];
        
        
        
    }];
    
    [self.view addSubview:segment];
    segment.backgroundColor = UIColorHex(0xffffff);
    self.segmentView = segment;
    
}

- (void)setupContentView {
    
    
    ZJContentView *content = [[ZJContentView alloc] initWithFrame:CGRectMake(0, self.navH + 40, self.view.bounds.size.width, self.view.bounds.size.height - self.navH  - self.BotH - 40) segmentView:self.segmentView parentViewController:self delegate:self];
    content.backgroundColor = [UIColor purpleColor];
    self.contentView = content;
    [self.view addSubview:self.contentView];
    
}
- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}

- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    
    
    if (!reuseViewController) {
        reuseViewController = self.childVcs[index];
    }
    
    return reuseViewController;
}
- (NSArray *)setupChildVc {
    
    
    NSArray *childVcs = [NSArray arrayWithObjects:self.StruVC,self.DetailVC,nil];
    return childVcs;
}
-(DataStructureVC *)StruVC{
    
    if (!_StruVC) {
        _StruVC = [[DataStructureVC alloc] init];
        
    }
    _StruVC.isDay = self.isDay;
    _StruVC.statisType = self.statisType;
    _StruVC.currentTime = self.currentTime;
    _StruVC.shopID = self.shopID;
    _StruVC.isSale = self.isSale;
    _StruVC.searchType = self.searchType;
    _StruVC.followState = self.followState;
    _StruVC.crmTotalNum = self.crmTotalNum;
    return _StruVC;
}

-(DetailSubVC *)DetailVC{
    if (!_DetailVC) {
        _DetailVC = [[DetailSubVC alloc] init];
        
    }

    _DetailVC.isDay = self.isDay;
    _DetailVC.statisType = self.statisType;
    _DetailVC.currentTime = self.currentTime;
    _DetailVC.shopID = self.shopID;
    _DetailVC.isSale = self.isSale;
    _DetailVC.searchType = self.searchType;
    _DetailVC.followState = self.followState;
    return _DetailVC;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
